Skip to content

Add draftwise clarify [<feature>] — audit a product spec for gaps before drafting tech#65

Merged
4nkur merged 1 commit intomainfrom
feat/clarify
Apr 30, 2026
Merged

Add draftwise clarify [<feature>] — audit a product spec for gaps before drafting tech#65
4nkur merged 1 commit intomainfrom
feat/clarify

Conversation

@4nkur
Copy link
Copy Markdown
Owner

@4nkur 4nkur commented Apr 30, 2026

Summary

Adds a fourth drafting verb to the CLI that fits between new and tech. draftwise clarify reads an existing product-spec.md and prints an instruction for the host coding agent to audit it for gaps, walk the PM through them, and rewrite the spec in place.

The audit covers four categories:

  • Ambiguities — vague acceptance criteria, terms used inconsistently, undefined scope boundaries.
  • Untested assumptions — claims about user behavior, market, or technical feasibility that the spec hasn't validated.
  • Internal contradictions — one section saying X, another saying not-X.
  • Missing edge cases — empty data, errors, permissions, concurrency, large data.

Three-phase agent instruction: (1) read the spec end-to-end and surface 4-10 specific issues, each with a section/line pointer (skip the spec entirely if it's already tight); (2) walk the PM through them one-at-a-time, allowing defer / reject / answer; (3) rewrite the file in place — preserving YAML frontmatter and any sections the PM didn't touch. Hard rule built into the prompt: don't widen scope; if the PM's answer expands the feature, push back — that's a new spec, not a clarification.

Same auto-pick / multi-spec / unknown-slug ergonomics as tech and tasks. Errors when no .draftwise/ dir exists, when no product specs exist, or when the spec file is empty.

Why: drafted specs are uneven — some sections tight, others hand-wavy. Catching that before the technical spec gets drafted keeps the engineering plan from being built on a shaky foundation, and PMs don't have to re-litigate the same ambiguity in three files. Companion to a planned draftwise refine (different problem: re-synthesize after PM edits).

What changed

  • New prompt src/ai/prompts/clarify.js with buildAgentInstruction(slug) returning the three-phase instruction.
  • New command src/commands/clarify.js mirroring tech's shape (parseArgs, requireDraftwiseDir, listSpecs filter, auto-pick/positional/error paths).
  • Routed via COMMANDS in src/index.js; help block now lists clarify [<feature>] between new and tech.
  • 9 new tests in test/commands/clarify.test.js (missing .draftwise/, no specs, auto-pick single, slug arg, multi-spec error, unknown slug error, empty product spec error, four-category audit instruction content, parseArgs strict mode).
  • CHANGELOG [Unreleased] ### Added entry; CLAUDE.md and README.md updated.

Test plan

  • npm test — 250 passing
  • npm run lint — clean
  • Smoke: in a repo with one product spec, draftwise clarify auto-picks; with two specs and no slug, it errors with the available list; draftwise clarify <missing> errors with the available list.

…efore drafting tech

`draftwise clarify` reads `product-spec.md` and prints an instruction telling the host coding agent to audit it across four categories — ambiguities, untested assumptions, internal contradictions, and missing edge cases — present each issue with a specific line / section pointer, walk the PM through them one at a time (defer / reject / answer), then rewrite the file in place. The instruction explicitly tells the agent to preserve the YAML frontmatter (`depends_on` / `related`) and any sections the PM didn't touch, and to push back rather than rewrite if the answers expand scope ("that's a new spec, not a clarification").

Same shape as `tech` and `tasks`: auto-picks when one product spec exists; positional slug picks one when many; errors with the available list when ambiguous. Empty product spec errors with a hint to run `draftwise new` first. Routed through `COMMANDS` in `src/index.js`; sits between `new` and `tech` in the help output.

Why: drafted specs are uneven — some sections tight, others with hand-wavy acceptance criteria or untested assumptions buried in scope. Catching that *before* the technical spec is drafted means the engineering plan isn't built on a shaky foundation, and PMs don't have to re-litigate the same ambiguity in three files. Companion to `draftwise refine` (queued next): clarify is the upfront quality check, refine rewrites after PM edits.

Prompt at `src/ai/prompts/clarify.js`; command at `src/commands/clarify.js`. CLAUDE.md and README.md updated end-to-end.
@4nkur 4nkur merged commit 0c99318 into main Apr 30, 2026
2 checks passed
@4nkur 4nkur deleted the feat/clarify branch April 30, 2026 04:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant